package com.levelup.cr.web.helpers;

import com.levelup.cr.model.Node;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: denis_zavadsky
 * Date: 9/7/13
 * Time: 12:16 PM
 * To change this template use File | Settings | File Templates.
 */
public class RepositoryHelperBean {

    public String generateChildList(Node current){
        StringBuilder builder = new StringBuilder();
        builder.append("<li>").append(current.getName());

        for (Node child:current.getChilds()){
            builder.append("<ul>");
            if (child.getChilds()!=null && !child.getChilds().isEmpty()){
                builder.append(generateChildList(child));
            } else {
                builder.append("<li>").append(child.getName()).append("</li>");
            }
            builder.append("</ul>");
        }

        builder.append("</li>");
       return  builder.toString();
    }
}
